//
//  HZMTopicTableViewCell.m
//  糖糖大魔王
//
//  Created by 韩震明 on 15/10/23.
//  Copyright © 2015年 韩震明. All rights reserved.
//

#import "HZMTopicTableViewCell.h"

@implementation HZMTopicTableViewCell

- (void)dealloc
{
    [_titleLabel release];
    [_picImageView release];
    [_likeImageView release];
    [_likeLabel release];
    [_backOfTitle release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createMyCell];
    }
    return self;
}

- (void)createMyCell
{
    self.picImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.picImageView];
    [_picImageView release];
    self.picImageView.layer.cornerRadius = 5;
    self.picImageView.layer.masksToBounds = YES;
    
    self.backOfTitle = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"backOfTitle.png"]];
    [self.picImageView addSubview:self.backOfTitle];
    [_backOfTitle release];
    self.backOfTitle.alpha = 0.2;
    
    self.titleLabel = [[UILabel alloc] init];
    [self.picImageView addSubview:self.titleLabel];
    [_titleLabel release];
    self.titleLabel.font = [UIFont systemFontOfSize:18.0];
    self.titleLabel.textColor = [UIColor whiteColor];


    
    self.likeImageView = [[UIImageView alloc] init];
    [self.picImageView addSubview:self.likeImageView];
    [_likeImageView release];
    self.likeImageView.layer.cornerRadius = 5;
    self.likeImageView.layer.masksToBounds = YES;
    self.likeImageView.alpha = 0.9;
    
    self.likeLabel = [[UILabel alloc] init];
    [self.likeImageView addSubview:self.likeLabel];
    [_likeLabel release];
    self.likeLabel.font = [UIFont systemFontOfSize:8.0];
    self.likeLabel.textAlignment = NSTextAlignmentCenter;
    self.likeLabel.textColor = [UIColor whiteColor];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.picImageView.frame = CGRectMake(CONTENTWIDTH / 80, CONTENTHEIGHT / 30, 78 * CONTENTWIDTH / 80, 28 * CONTENTHEIGHT / 30);
    self.backOfTitle.frame = CGRectMake(0, 6 * self.picImageView.frame.size.height / 8, self.picImageView.frame.size.width,  3 * self.picImageView.frame.size.height / 11);
    self.titleLabel.frame = CGRectMake(self.picImageView.frame.size.width / 30, 6 * self.picImageView.frame.size.height / 8, 28 * self.picImageView.frame.size.width / 30, self.picImageView.frame.size.height / 6);
    self.likeImageView.frame = CGRectMake(7 * self.picImageView.frame.size.width / 8, 5, 2 * self.picImageView.frame.size.width / 17, 3 * self.picImageView.frame.size.height / 10);
    self.likeLabel.frame = CGRectMake(0, self.likeImageView.frame.size.height / 2, self.likeImageView.frame.size.width, self.likeImageView.frame.size.height / 2);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
